<?php
/**
 * 会员相关
 * @author fanzhanao
 *
 */
class index_controller_cartoon extends SnsController{
	
	private $cartoon 	= 	'';
	private $chapter	=	'';
	private $comment	=	'';
	public function __construct($app, $controller){
		parent::__construct($app, $controller);
		$this->cartoon	=	Model::factory('cartoon_model_data');
		$this->chapter	=	Model::factory('cartoon_model_chapter');
        $this->avatar 	= 	Model::factory('member_util_avatar');
        $this->frameView	=	VIEW_PATH.'/index.phtml';
	}
	
	public function list_action(){
		$recom_home = cartoon_util_interface::cacheGetRecomCT(CONST_CT::RECOM_HOME );
		$new	=	cartoon_util_interface::cacheGetRecomCT(CONST_CT::RECOM_NEW );
		
		$this->ret = array('recom'=>$recom_home,'new' => $new);
		
		if(self::$login['uid']){
			$this->ret['userinfo']	=	friends_util_cache::getUserInfo(self::$login['uid']);
		}
		
	}
	
	/**
	 * 给漫画打分
	 *
	 */
	public function score_action(){
		$this->requireLogin();
		$cartoon_id = _('cartoon_id');
		$uid = self::$login['uid'];
		$score = floatval(_('score'));
		$rs = Model::factory('cartoon_model_data')->score($cartoon_id,$uid,$score);
		if($rs == true){
			$this->ret = self::success();
		}else{
			if($rs >100){
				$this->ret = self::failure('你已经评过分！');
			}else $this->ret = self::failure('评分失败，请稍后再试');
		}
	}
	
	/**
	 * 添加分享
	 *
	 */
	public function share_action(){
		$this->requireLogin();
		$this->_renderJson();
		$uid = self::$login['uid'];
		$cid = _('cid');
		$rs = Model::factory('index_model_data')->add_share($uid,$cid);
		if($rs < 0 ){
			$this->ret = self::failure($rs);
		}else{
			$this->ret = self::success();
		}
	}
}
?>